#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e5 + 10;
int a[N],c[N],f[N];
set<int> s;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) s.insert(i);
	for (int i = 1; i <= n; i++) {
		if (a[i] >= 1 && a[i] <= n && c[a[i]] == 0) {
			c[a[i]]++;
			f[i] = 1;
			s.erase(a[i]);
		}
	}
	
	vector<pair<int, int>> v;
	for (int i = 1; i <= n; i++) {
		if (!f[i]) {
			for (auto x : s) {
				v.push_back({ i,x });
				s.erase(x);
				break;
			}
		}
	}

	cout << v.size() << endl;
	for (auto i : v) {
		cout << i.first << " " << i.second << endl;
	}
	return 0;
}